package com.xlh.dto.course;

import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

/**
 * 资源
 * <p>
 * Created by lx on 2019/2/12 0012.
 */
@Data
public class ResourceDTO {

    @ApiModelProperty(value = "章节id")
    private Long chapterId;

    @JsonIgnore
    @ApiModelProperty(value = "资源id")
    private Long resourceId;

    @JsonIgnore
    @ApiModelProperty(value = "章节资源id")
    private Long chapterResourceId;

    @JsonIgnore
    @ApiModelProperty(value = "类型")
    private Integer type;

    @ApiModelProperty(value = "系统中资源文件名称")
    private String name;

    @ApiModelProperty(value = "显示名称")
    private String showName;

    @ApiModelProperty(value = "存储的文件名称")
    private String fileName;

    @ApiModelProperty(value = "文件地址")
    private String filePath;

    @ApiModelProperty(value = "图标地址")
    private String iconPath;

    @ApiModelProperty(value = "文件内容")
    private String content;

    @ApiModelProperty(value = "html文件内容")
    private String htmlContent;

    @ApiModelProperty(value = "备注")
    private String remark;

    @ApiModelProperty(value = "教师控制学生时是否允许显示 true：允许学生端下载 false：不允许学生端下载")
    private boolean teacherOpenSwitch = false;

    @ApiModelProperty(value = "是否允许下载")
    private boolean download = true;

    @ApiModelProperty(value = "允许被修改")
    private boolean allowModify = true;

    public String getShowName() {
        if (StringUtils.isBlank(showName)) {
            return name;
        }
        return showName;
    }
}
